<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
    <th:block th:fragment="script">
        <!-- Google Analytics (if configured) -->
        <th:block th:if="${theme.config.google_analytics_id}">
            <script async th:src="'https://www.googletagmanager.com/gtag/js?id=' + ${theme.config.google_analytics_id}"></script>
            <script th:inline="javascript">
                window.dataLayer = window.dataLayer || [];
                function gtag(){dataLayer.push(arguments);}
                gtag('js', new Date());
                gtag('config', /*[[${theme.config.google_analytics_id}]]*/ '');
            </script>
        </th:block>
        
        <!-- Additional JavaScript -->
        <script>
            // Contact button click tracking
            document.querySelectorAll('.btn-contact, .btn-contact-large').forEach(function(btn) {
                btn.addEventListener('click', function() {
                    // Track contact button clicks
                    if (typeof gtag !== 'undefined') {
                        gtag('event', 'contact_click', {
                            'event_category': 'engagement',
                            'event_label': 'contact_button'
                        });
                    }
                });
            });
            
            // Product view tracking
            document.querySelectorAll('.product-card a, .btn-view-details').forEach(function(link) {
                link.addEventListener('click', function() {
                    if (typeof gtag !== 'undefined') {
                        gtag('event', 'product_view', {
                            'event_category': 'ecommerce',
                            'event_label': 'product_click'
                        });
                    }
                });
            });
        </script>
    </th:block>
</body>
</html>